﻿using System;
using System.Windows.Media;
using System.Windows.Data;

namespace Eniux.Windows.Controls.Core.Converters
{
    /// <summary>
    /// 去除颜色的透明度值
    /// </summary>
    public class TransparentToNoTransparent : IValueConverter
    {
        /// <summary>
        /// 将具有透明度的颜色转为非透明的颜色
        /// </summary>
        /// <param name="value">颜色值</param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                Color c = (Color)ColorConverter.ConvertFromString(value.ToString());
                c.A = 255;
                return new SolidColorBrush(c);
            }
            return value;
        }
        /// <summary>
        /// 不做任何操作
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }
}
